import request from '@/utils/request';
import moment from 'moment'
import {fixedZero, getEW} from '@/utils/utils';

export async function query({...resetParams}) {
  return request(`/guest/revenue_overview`,{
    method:'GET',
    params:{
      ...resetParams,
      company_ids:getEW(resetParams.company_ids),
    }
  });
}

export async function queryPress({...resetParams}) {
  return request(`/guest/pressure_sensors`,{
    method:'GET',
    params:{
      ...resetParams,
      company_ids:getEW(resetParams.company_ids),
    }
  });
}
export async function queryWorkstations({...resetParams}) {
  return request(`/guest/all_workstations`,{
    method:'GET',
    params:{
      ...resetParams,
      template:27,
      order_direction:'asc',
      order_column:'name',
      company_ids:getEW(resetParams.company_ids),
    }
  });
}
export async function queryWorkstations3({...resetParams}) {
  return request(`/guest/all_workstations`,{
    method:'GET',
    params:{
      ...resetParams,
      template:41,
      order_direction:'asc',
      order_column:'name',
      company_ids:getEW(resetParams.company_ids),
    }
  });
}
export async function queryAllWorkstations({...resetParams}) {
  return request(`/guest/all_workstations`,{
    method:'GET',
    params:{
      ...resetParams,
      order_direction:'desc',
      company_ids:getEW(resetParams.company_ids),
    }
  });
}


export async function queryRevenue({...resetParams}) {
  return request(`/guest/revenue_overview`,{
    method:'GET',
    params:{
      days:30,
      company_ids:getEW(resetParams.company_ids),
    }
  });
}

export async function queryMeter({...resetParams}) {
  return request(`/guest/meter_overview`,{
    method:'GET',
    params:{
      days:30,
      company_ids:getEW(resetParams.company_ids),
    }
  });
}

export async function queryWaterworks({...resetParams}) {
  return request(`/guest/waterworks_device_latest_data`,{
    method:'GET',
    params:{
      ...resetParams,
      company_ids:getEW(resetParams.company_ids),
    }
  });
}

export async function queryWaterworksHistory({...resetParams}) {
  return request(`/guest/waterworks_device_historical_data`,{
    method:'GET',
    params:{
      items:['item4','item8','item10'],
      start_time:`${(new Date()).getFullYear()}-${fixedZero((new Date()).getMonth()+1)}-${fixedZero((new Date()).getDate())} 00:00:00`,
      end_time:moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
      ...resetParams,
      company_id:'647076256457691137'
    }
  });
}

